package com.zl.tby.core.exception;


import com.zl.tby.core.constant.HttpStatus;
import lombok.Getter;

/**
 * author: Nyx
 * date: 2023/5/18 13:57
 * description: 自定义异常
 */

public class GlobalException extends RuntimeException {

    private String message;

    @Getter
    private Integer code;

    /**
     * 空构造方法，避免反序列化问题
     */
    public GlobalException() {
    }

    public GlobalException(String message) {
        this.message = message;
        this.code = HttpStatus.OK;
    }

    public GlobalException(String message, Integer code) {
        this.message = message;
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public GlobalException setMessage(String message) {
        this.message = message;
        return this;
    }

}
